home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / citsrc6K05.lha / verify.c < prev    next >
C/C++ Source or Header  |  1996-10-13  |  27KB  |  849 lines

  1. /*  Citadel Verify Database */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "ctdl.h"
  5. #include "c68door.h"
  6. extern CONFIG      cfg;            /* A buncha variables           */
  7. extern logBuffer   logBuf;         /* Pippul buffer                */
  8. extern FILE        *logfl;         /* log file descriptor          */
  9. extern LogTable    *logTab;
  10. extern int         thisLog;
  11. extern FILE            *netfl, *roomfl;
  12. extern NetBuffer   netBuf;
  13. extern NetTable    *netTab;
  14. extern rTable      *roomTab;         /* RAM index of rooms              */
  15. extern EVENT       *EventTab;        /* Events Table */
  16. extern int          TopFloor;        /* limit on floor */
  17. extern struct floor  *FloorTab;
  18.  
  19. void Process_Msg(MessageBuffer  *msg);
  20. void Do_Room_Stats(long total);
  21. void Print_Counts(struct counts *ptr );
  22. void Do_Message(MessageBuffer  *,int);
  23. void Verify_Messages(void);
  24. int MsgLen(MessageBuffer  *);
  25. void ShowHash(void);
  26. void showlog(int);
  27. char *LastOn(long lastdate, char s);
  28. void Do_Boolean(char *,short,short);
  29. void Verify_Config(void);
  30. void Verify_Log(void);
  31. void Verify_Room(void);
  32. void Verify_Floor(void);
  33. void Verify_Events(void);
  34. void crashout(char *);
  35. void Check_codeBuf(char *,long,short);
  36. void Check_Shared(void);
  37. void Do_nflags(struct nflags *);
  38. void Do_Multi_Net_Data(MULTI_NET_DATA);
  39. void Do_Shared_Room(SharedRoom *);
  40. void Do_Door_Data(void);
  41. void Do_Net_Data(void);
  42. void Do_NetBuf_Data(int slot);
  43. short Vflag;   /* TRUE - Verbose output( config) */
  44. short Lflag;   /* TRUE - Verbose output( user log) */
  45. short Nflag;   /* TRUE - Verbose output( ctdlnet.sys ) */
  46. short Rflag;   /* TRUE - Verbose output( Room data ) */
  47. short Dflag;   /* TRUE - Verbose output(Doors data ) */
  48. short Mflag;   /* TRUE - Verbose output(Message data ) */
  49. short Eflag;   /* TRUE - Process Event data */
  50. short Fflag;   /* TRUE - Process Floor Table */
  51.  
  52. char MControl;    /* selective dump control */
  53. int  mPrintf(char *format, ...) {return 0; }  /* stub to quiet the linker */
  54.  
  55.  
  56. void crashout(str)
  57. char *str;
  58.   {
  59.   printf(str);
  60.   exit(10);
  61.  
  62.   }
  63. int  main(int,char **);
  64. int  main(argc,argv)
  65. int  argc;
  66. char **argv;
  67.   {
  68.   SYS_FILE fn;
  69.   /* Process CONFIG  */
  70.   cfg.weAre = UTILITY;
  71.   if( argc > 1 )
  72.     {
  73.     Fflag = Eflag = Dflag = Rflag = Vflag = Lflag = Mflag = Nflag = FALSE;
  74.     MControl = '\0';
  75.     }
  76.   else Fflag =  Eflag = Dflag = Rflag = Vflag = Lflag = Mflag = Nflag = TRUE;  /* default is all */
  77.   printf("Citadel Verify Database Utility Version %s\n", VERSION_NAME);
  78.   for( ;--argc>0; )
  79.     {
  80.     if( *argv[argc] == '-' )
  81.       {
  82.       switch ( argv[argc][1])
  83.         {
  84.         case 'a' :
  85.         case 'A' : Fflag = Mflag = Eflag = Dflag = Lflag = Vflag = Rflag = Nflag = TRUE;break;
  86.         case 'd' :
  87.         case 'D' : Dflag = TRUE;break;
  88.         case 'e' :
  89.         case 'E' : Eflag = TRUE;break;
  90.         case 'f' :
  91.         case 'F' : Fflag = TRUE;break;
  92.         case 'l' :
  93.         case 'L' : Lflag = TRUE;break;
  94.         case 'm' :
  95.         case 'M' : Mflag = TRUE;MControl = argv[argc][2];break;
  96.         case 'n' :
  97.         case 'N' : Nflag = TRUE;break;
  98.         case 'r' :
  99.         case 'R' : Rflag = TRUE;break;
  100.         case 'v' :
  101.         case 'V' : Vflag = TRUE;break;
  102.         default:
  103.         printf("illegal option ignored:%s\n",argv[argc]);
  104.         printf(" Valid options are:\n");
  105.         printf("   -L User Log data  -V config data\n");
  106.         printf("   -R room data      -M Messages data\n");
  107.         printf("   -N net data       -E Event data\n");
  108.         printf("   -D Door Data      -F Floor data        -A All of the Above\n");
  109.         };
  110.  
  111.       };
  112.  
  113.     };
  114.   if (!readSysTab(FALSE, TRUE)) exit(100);
  115.   Verify_Config();             /* Verify the data in the main database */
  116.   /* Process the User Log */
  117.   sprintf(fn, "%sctdllog.sys", &cfg.logArea);
  118.   if ((logfl = fopen(fn, "rb")) == NULL)
  119.     {
  120.     printf("Can't open the Citadel log!\n");
  121.     exit(1);
  122.  
  123.     }
  124.   initLogBuf(&logBuf);
  125.   Verify_Log();
  126.   if( cfg.BoolFlags.netParticipant )
  127.     {
  128.     /* process network information */
  129.     sprintf(fn, "%sctdlnet.sys", &cfg.netArea);
  130.     openFile(fn, &netfl);
  131.     initNetBuf(&netBuf);
  132.  
  133.     };
  134.   /* open room file */
  135.   sprintf(fn, "%sctdlroom.sys", &cfg.roomArea);
  136.   openFile(fn, &roomfl);
  137.   Verify_Room();
  138.   fclose(roomfl);
  139.   /* close room file */
  140.   Verify_Floor();
  141.   Do_Door_Data();
  142.   Verify_Messages();    /* process the messages */
  143.   Verify_Events();      /* Event Data processing */
  144.   return 0;
  145.   }
  146.  
  147. struct  namelist
  148.   {
  149.   char *GenName;
  150.   int  GenVal;
  151.  
  152.   };
  153.  
  154. typedef struct namelist GenList;
  155.  
  156.   /***  INDENT-OFF ***/
  157. #define MAXDAYS  (8)
  158. #define MAXTYPES (3)
  159.  
  160. static GenList EvnDays[MAXDAYS] =
  161.   {
  162.     {    "Sun", SUNDAYS     },    {    "Mon", MONDAYS     },
  163.     {    "Tue", TUESDAYS    },    {    "Wed", WEDNESDAYS  },
  164.     {    "Thu", THURSDAYS   },    {    "Fri", FRIDAYS     },
  165.     {    "Sat", SATURDAYS   },    {    "All", ALL_DAYS    }
  166.   };
  167.  
  168. static GenList EvnTypes[MAXTYPES] =
  169.   {
  170.     {    "preempt",     TYPREEMPT  },    {    "non-preempt", TYNON      },
  171.     {    "quiet",       TYQUIET    }
  172.   };
  173.  
  174.  
  175. static GenList EvCls[EVENT_CLASS_COUNT] =
  176.   {
  177.     {    "network",             CLNET        },
  178.     {    "external",            CLEXTERN     },
  179.     {    "relative",            CLREL        },
  180.     {    "dl-time",             CL_DL_TIME   },
  181.     {    "anytime-net",         CL_ANYTIME_NET   },
  182.     {    "door-limit",          CL_DOOR_TIME },
  183.     {    "autodoor",            CL_AUTODOOR  },
  184.     {    "chat-on",             CL_CHAT_ON   },
  185.     {    "chat-off",            CL_CHAT_OFF  },
  186.     {    "redirect",            CL_REDIRECT  },
  187.     {    "newusers-allowed",    CL_NEWUSERS_ALLOWED   },
  188.     {    "newusers-disallowed", CL_NEWUSERS_DISALLOWED   },
  189.     {    "until-done-net",      CL_UNTIL_NET  },
  190.     {    "netcache",            CL_NETCACHE   },
  191.     };
  192.  
  193.  /**  INDENT-ON **/
  194. char *fake = "Unknown nnn  ";
  195.  
  196. char *Look_Up(int value,  GenList list[], int limit )
  197.  {
  198.  int i;
  199.  for( i=0; i<limit; i++) if( list[i].GenVal == value ) return list[i].GenName;
  200.  sprintf(&fake[8],"%3d",value);
  201.  return fake;
  202.  }
  203.  
  204. void Verify_Floor()
  205.   {
  206.   int rover;
  207.   for ( rover=0; rover < TopFloor; rover++)
  208.     {
  209.     if( FloorTab[rover].FlInuse )
  210.       {
  211.       printf(" Floor slot[%d] in use  Name:%20s Moderator:%s\n",
  212.         rover, FloorTab[rover].FlName,
  213.        ( FloorTab[rover].FlModerator[0] != '\0' ? FloorTab[rover].FlModerator : "No Moderator") );
  214.       }
  215.     else  printf(" Floor slot[%d] not in use\n",rover);
  216.  
  217.     };
  218.   }
  219.  
  220. void Verify_Events()
  221.   {
  222.   int i,j;
  223.   int hrs,mins;
  224.   long minutes;
  225.   int day;
  226.   if( !Eflag )return;  /* exit if not requested */
  227.   printf("\n\nThere are %d events\n",cfg.EvNumber);
  228.   for( i=0; i< cfg.EvNumber; i++)
  229.     {
  230.     hrs = EventTab[i].EvDur / 60;
  231.     mins= EventTab[i].EvDur % 60;
  232.     printf("\nEvent Number: %d Duration:%d(%d:%02.2d)   ",i,EventTab[i].EvDur, hrs, mins);
  233.     printf("Event Type: %s\n", Look_Up(EventTab[i].EvType,EvnTypes,MAXTYPES) );
  234.     printf("Event Warning:%s\n",( cfg.codeBuf+EventTab[i].EvWarn) );
  235.     printf("Event Class:%s   ",Look_Up(EventTab[i].EvClass,EvCls,EVENT_CLASS_COUNT) );
  236.     printf("Event EvExitVal:%08.8lX :",EventTab[i].EvExitVal);
  237.     for (j = 0; j < 32; j++)
  238.       {
  239.       if (( 1l << j ) & EventTab[i].EvExitVal) printf("%d ", j + 1);
  240.       };
  241.     printf("\n");
  242.     hrs = EventTab[i].EvDur / 60;
  243.     mins= EventTab[i].EvDur % 60;
  244.     printf("Event Minutes: %d(%d:%02.2d)\n",EventTab[i].EvMinutes, hrs, mins);
  245.     day = 1;
  246.     minutes = EventTab[i].EvMinutes;
  247.     while( minutes >= 1440)
  248.       {
  249.       day <<= 1;
  250.       minutes -= 1440;
  251.       };
  252.     hrs = minutes / 60;
  253.     mins= minutes % 60;
  254.     printf("Event Day: %s  Start Time:%ld(%d:%02.2d)\n",Look_Up(day,EvnDays, MAXDAYS), minutes, hrs, mins);
  255.     switch (EventTab[i].EvClass)
  256.       {
  257.       case CL_ANYTIME_NET:
  258.         printf("Anytime DeadTime: %ld  Anytime Duration: %d\n",
  259.         EventTab[i].vars.Anytime.EvDeadTime, EventTab[i].vars.Anytime.EvAnyDur);
  260.         break;
  261.       case CL_AUTODOOR:
  262.         printf("AutoDoor for User:%s\n", EventTab[i].vars.EvUserName);
  263.         break;
  264.       case CL_REDIRECT:
  265.         printf("Redirect incoming: System:%s\n"
  266.         ,EventTab[i].vars.Redirect.EvSystem);
  267.         printf("Directory:%s Filename:%s\n",
  268.         (EventTab[i].vars.Redirect.EvHomeDir + cfg.codeBuf)
  269.         ,EventTab[i].vars.Redirect.EvFilename);
  270.         break;
  271.       };
  272.     };
  273.   }
  274.  
  275.  
  276.  
  277. void Verify_Room()
  278.   {
  279.   short Index;
  280.   for (Index = 0; Index < MAXROOMS; Index++)
  281.     {
  282.     if( Rflag )printf("\nRoom Slot #%d:",Index);
  283.     if(   roomTab[Index].rtflags.INUSE )
  284.       {
  285.       if( Index < 3 )
  286.         {
  287.         if( roomTab[Index].rtFlIndex != 0 )
  288.           {
  289.           printf("\nInitial Room not on Base Floor!\n");
  290.  
  291.           };
  292.  
  293.         };
  294.       if( Rflag )
  295.         {
  296.         printf("%20s Last Message:%ld Last Netted message:%ld\n",
  297.         roomTab[Index].rtname,roomTab[Index].rtlastMessage,roomTab[Index].rtlastNet);
  298.         printf("Floor Index:%d\n", roomTab[Index].rtFlIndex);
  299.         Do_Boolean("Public            ",roomTab[Index].rtflags.PUBLIC,         FALSE);
  300.         Do_Boolean("Directory         ",roomTab[Index].rtflags.ISDIR,          FALSE);
  301.         Do_Boolean("Permanent         ",roomTab[Index].rtflags.PERMROOM,       TRUE);
  302.         Do_Boolean("Skipped           ",roomTab[Index].rtflags.SKIP,           FALSE);
  303.         Do_Boolean("Uploadable        ",roomTab[Index].rtflags.UPLOAD,         FALSE);
  304.         Do_Boolean("Downloadable      ",roomTab[Index].rtflags.DOWNLOAD,       TRUE);
  305.         Do_Boolean("Shared            ",roomTab[Index].rtflags.SHARED,         FALSE);
  306.         Do_Boolean("Archived          ",roomTab[Index].rtflags.ARCHIVE,        FALSE);
  307.         Do_Boolean("Anonymous         ",roomTab[Index].rtflags.ANON,           TRUE);
  308.         Do_Boolean("Net Downloadable  ",roomTab[Index].rtflags.NO_NET_DOWNLOAD,FALSE);
  309.         Do_Boolean("Invitational      ",roomTab[Index].rtflags.INVITE,         FALSE);
  310.         Do_Boolean("Automaticly Netted",roomTab[Index].rtflags.AUTO_NET,       TRUE);
  311.         Do_Boolean("All Users Netted  ",roomTab[Index].rtflags.ALL_NET,        FALSE);
  312.         Do_Boolean("Read Only         ",roomTab[Index].rtflags.READ_ONLY,      TRUE);
  313.  
  314.         };
  315.  
  316.       }
  317.     else if( Rflag )printf(" Not in use at this time\n");
  318.  
  319.     };
  320.   if( Nflag )Check_Shared();
  321.  
  322.   }
  323. void Do_Net_Data()
  324.   {
  325.   printf("\nNode Name:%-22s  Node Id: %s\n",netBuf.netName, netBuf.netId);
  326.   printf("Short Name:%c%c%c  Passwords: Our(%s) Their(%s)\n",
  327.   (isprint(netBuf.nbShort[0]) ? netBuf.nbShort[0] : '*'),
  328.   (isprint(netBuf.nbShort[1]) ? netBuf.nbShort[1] : '*'),
  329.   (isprint(netBuf.nbShort[2]) ? netBuf.nbShort[2] : '*'),
  330.   netBuf.OurPwd, netBuf.TheirPwd);
  331.   printf("baudCode:%c nbGen: %c access:%s\n",
  332.   netBuf.baudCode, netBuf.nbGen, netBuf.access);
  333.   printf("nbRoute:%d nbRouteGen:%d nbHiRouteInd: %d nbLastConnect: %x\n",
  334.   netBuf.nbRoute, netBuf.nbRouteGen, netBuf.nbHiRouteInd, netBuf.nbLastConnect);
  335.   }
  336.  
  337. void Check_Shared()
  338.   {
  339.   short netrover;
  340.   for( netrover=0; netrover < cfg.netSize; netrover++)
  341.     {
  342.     getNet(netrover,&netBuf);
  343.     Do_NetBuf_Data(netrover);
  344.     printf("\nnetTab[%d]:",netrover);
  345.     if( netTab[netrover].ntflags.in_use )
  346.       {
  347.       printf(" In use\n");
  348.       printf(" ntnmhash: %d  ntidhash: %d  Short name:%c%c%c Generation: %d\n",
  349.       netTab[netrover].ntnmhash,netTab[netrover].ntidhash,
  350.       (isprint(netTab[netrover].ntShort[0]) ? netTab[netrover].ntShort[0] : '*'),
  351.       (isprint(netTab[netrover].ntShort[1]) ? netTab[netrover].ntShort[1] : '*'),
  352.       (isprint(netTab[netrover].ntShort[2]) ? netTab[netrover].ntShort[2] : '*'),
  353.       netTab[netrover].ntGen);
  354.       Do_nflags(&netTab[netrover].ntflags);
  355.       Do_Multi_Net_Data(netTab[netrover].ntMemberNets);
  356.       Do_Shared_Room(netTab[netrover].netTRooms);
  357.       Do_Net_Data();
  358.       }
  359.     else
  360.       {
  361.       printf("Not in use\n");
  362.  
  363.       };
  364.  
  365.     };
  366.  
  367.   }
  368. void Do_nflags(ntflags)
  369. struct nflags *ntflags;
  370.   {
  371.   Do_Boolean("normal_mail   ",ntflags->normal_mail,FALSE);
  372.   Do_Boolean("in_use        ",ntflags->in_use,FALSE);
  373.   Do_Boolean("room_files    ",ntflags->room_files,TRUE);
  374.   Do_Boolean("local         ",ntflags->local,FALSE);
  375.   Do_Boolean("spine         ",ntflags->spine,FALSE);
  376.   Do_Boolean("send_files    ",ntflags->send_files,TRUE);
  377.   Do_Boolean("is_spine      ",ntflags->is_spine,FALSE);
  378.   Do_Boolean("OtherNet      ",ntflags->OtherNet,FALSE);
  379.   Do_Boolean("HasRouted     ",ntflags->HasRouted,TRUE);
  380.   Do_Boolean("RouteFor      ",ntflags->RouteFor,FALSE);
  381.   Do_Boolean("RouteTo       ",ntflags->RouteTo,FALSE);
  382.   Do_Boolean("Stadel        ",ntflags->Stadel,TRUE);
  383.   Do_Boolean("RouteLock     ",ntflags->RouteLock,FALSE);
  384.   Do_Boolean("ExternalDialer",ntflags->ExternalDialer,FALSE);
  385.   Do_Boolean("NoDL          ",ntflags->NoDL,TRUE);
  386.   Do_Boolean("MassTransfer  ",ntflags->MassTransfer,FALSE);
  387.   Do_Boolean("Zip           ",ntflags->Zip,FALSE);
  388.   Do_Boolean("Zoo           ",ntflags->Zoo,TRUE);
  389.   Do_Boolean("Arc           ",ntflags->Arc,FALSE);
  390.   Do_Boolean("Lha           ",ntflags->Lha,FALSE);
  391.  
  392.   }
  393. void Do_Multi_Net_Data(MN)
  394. MULTI_NET_DATA MN;
  395.   {
  396.   short i;
  397.   printf(" Member of Nets:");
  398.   for(i=0; i<MAX_NET-1;i++) if( ((1<<i) & MN) !=0 )printf(" %d",i+1);
  399.   printf("\n");
  400.   if( (MN & 0x80000000) != 0)printf("Priority Mail\n");
  401.  
  402.   }
  403. void Do_Shared_Room(nRms)
  404. SharedRoom *nRms;
  405.   {
  406.   int slot;
  407.   for(slot = 0; slot < SHARED_ROOMS; slot++)
  408.     {
  409.     if( (nRms->srgen & 0x8000) )
  410.       {
  411.       printf(" \nSR[%d]:  lM:%ld  Mode:",slot,  nRms->lastMess);
  412.       switch (GetMode(nRms->mode))
  413.         {
  414.         case            PEON: printf("Peon            "); break;
  415.         case        REG_HOST: printf("Reg Host        "); break;
  416.         case        BACKBONE: printf("Backbone        "); break;
  417.         case   PASS_BACKBONE: printf("Passive Backbone"); break;
  418.         case ACTIVE_BACKBONE: printf("Active Backbone "); break;
  419.         default:              printf("Unknown");
  420.         };
  421.       printf("  F:%s srgen:%x srslot: %d",
  422.       (GetFA(nRms->mode) != 0 ? "YES":"NO "),nRms->srgen,nRms->srslot);
  423.       };
  424.       nRms++;
  425.     };
  426.   }
  427. void Check_codeBuf(str,data,control)
  428. char *str;
  429. long data;
  430. short control;   /* TRUE - Newline if verbose operation */
  431.   {
  432.   if( data >= MAXCODE )
  433.     {
  434.     printf("\nInvalid values(%d) for offset:%s\n",data,str);
  435.  
  436.     }
  437.   else
  438.     {
  439.     if(Vflag)
  440.       {
  441.       char *d;
  442.       d = &cfg.codeBuf[0];
  443.       printf("%-20s(%ld):%s%c",str,data,
  444.       (data == 0 ? "Undefined" : &d[data]),(control ? '\n':' '));
  445.  
  446.       };
  447.  
  448.     };
  449.  
  450.   }
  451. void Verify_Config()
  452.   {
  453.   short i;
  454.   if( Vflag )
  455.     {
  456.     printf("\nmaxMSector:%d ",cfg.maxMSector);
  457.     printf("Message Old::%ld New:%ld\n",cfg.oldest,cfg.newest);
  458.  
  459.     };
  460.   Check_codeBuf("Node Name",  cfg.nodeName,TRUE);
  461.   Check_codeBuf("Node Id",    cfg.nodeId,FALSE);
  462.   Check_codeBuf("Node Domain",cfg.nodeDomain,TRUE);
  463.   Check_codeBuf("Node Title", cfg.nodeTitle,TRUE);
  464.   Check_codeBuf("Main Floor", cfg.MainFloor,FALSE);
  465.   Check_codeBuf("Base Room",  cfg.bRoom, TRUE);
  466.   for(i=0;i<7;i++)
  467.     {
  468.     Check_codeBuf("Dial Prefix",cfg.DialPrefixes[i],TRUE);
  469.  
  470.     };
  471.   Check_codeBuf("Dial Suffix",cfg.netSuffix,TRUE);
  472.   if( Vflag )
  473.     {
  474.     printf("Max File:%d Area Size: %d receptArea:%s\n",
  475.     cfg.maxFileSize, cfg.sizeArea, &cfg.receptArea);
  476.     printf("Sysop:%s CryptSeed:%d InitColumns:%d LoginAttempts:%d Audit: %d(%s)\n",
  477.     cfg.SysopName,cfg.cryptSeed,cfg.InitColumns,cfg.LoginAttempts,
  478.     cfg.Audit,( cfg.Audit == 0 ? "None":(cfg.Audit == 1? "Normal":"No Net") ) );
  479.     printf("  homeArea:%s\n",&cfg.homeArea);
  480.     printf("   msgArea:%s\n",&cfg.msgArea);
  481.     printf("  msg2Area:%s\n",&cfg.msg2Area);
  482.     printf("   logArea:%s\n",&cfg.logArea);
  483.     printf("  roomArea:%s\n",&cfg.roomArea);
  484.     printf("   netArea:%s\n",&cfg.netArea);
  485.     printf("domainArea:%s\n",&cfg.domainArea);
  486.     printf(" auditArea:%s\n",&cfg.auditArea);
  487.     printf(" floorArea:%s\n",&cfg.floorArea);
  488.     printf("  holdArea:%s\n",&cfg.holdArea);
  489.     printf("sysBaud:%d netSiz:%d DomainHandlers:%d\n"
  490.     ,cfg.sysBaud,cfg.netSize,cfg.DomainHandlers);
  491.  
  492.     };
  493.   Check_codeBuf("Mail Hub",cfg.MailHub,TRUE);
  494.   if( Vflag )
  495.     {
  496.     printf("Domain display Format:%s\n",&cfg.DomainDisplay[0]);
  497.     printf("EvNumber:%d weAre:%d paramVers:%d\n",cfg.EvNumber,cfg.weAre,cfg.paramVers);
  498.     printf("MaxLog size:%d ",cfg.MAXLOGTAB);
  499.     printf("Mail  Slots:%d ",cfg.MailSlots);
  500.     printf("Msgs Per room:%d\n",cfg.MsgsPerrm);
  501.     printf("Max Rooms:%d ",cfg.MaxRooms);
  502.     printf("Shared Rooms:%d\n",cfg.SharedRooms);
  503.     printf("Next msg slot: %d/%d Anon Mail Max Length:%d\n",
  504.     cfg.catChar,cfg.catSector,cfg.AnonMailLength);
  505.     printf("Log entries are %d in size\n",cfg.sizeLTentry);
  506.     printf("Console Timeout:%d\n",cfg.ConTimeOut);
  507.     printf("Sysop Archive:%s\n",cfg.SysopArchive);
  508.     Do_Boolean("HoldOnLost    ", cfg.BoolFlags.HoldOnLost    ,FALSE);
  509.     Do_Boolean("mirror        ", cfg.BoolFlags.mirror        ,FALSE);
  510.     Do_Boolean("unlogEnterOk  ", cfg.BoolFlags.unlogEnterOk  ,TRUE);
  511.     Do_Boolean("unlogReadOk   ", cfg.BoolFlags.unlogReadOk   ,FALSE);
  512.     Do_Boolean("nonAideRoomOk ", cfg.BoolFlags.nonAideRoomOk ,FALSE);
  513.     Do_Boolean("noMail        ", cfg.BoolFlags.noMail        ,TRUE);
  514.     Do_Boolean("noChat        ", cfg.BoolFlags.noChat        ,FALSE);
  515.     Do_Boolean("netParticipant", cfg.BoolFlags.netParticipant,FALSE);
  516.     Do_Boolean("aideSeeAll    ", cfg.BoolFlags.aideSeeAll    ,TRUE);
  517.     Do_Boolean("debug         ", cfg.BoolFlags.debug         ,FALSE);
  518.     Do_Boolean("NetDft        ", cfg.BoolFlags.NetDft        ,FALSE);
  519.     Do_Boolean("SysopEditor   ", cfg.BoolFlags.SysopEditor   ,TRUE);
  520.     Do_Boolean("IsDoor        ", cfg.BoolFlags.IsDoor        ,FALSE);
  521.     Do_Boolean("RouteMail     ", cfg.BoolFlags.RouteMail     ,FALSE);
  522.     Do_Boolean("DoorDft       ", cfg.BoolFlags.DoorDft       ,TRUE);
  523.     Do_Boolean("AnonSessions  ", cfg.BoolFlags.AnonSessions  ,FALSE);
  524.     Do_Boolean("DL_Default    ", cfg.BoolFlags.DL_Default    ,FALSE);
  525.     Do_Boolean("NetScanBad    ", cfg.BoolFlags.NetScanBad    ,TRUE);
  526.     printf("SysOp Editor:%s\n",cfg.DepData.Editor);
  527.     printf("SysOp Editor Area:%s\n",cfg.DepData.EditArea);
  528.     printf("Sysdependant Modem:%s\n",cfg.DepData.ModemSetup);
  529.     printf("Sysdependant Modem Init:%s\n",cfg.DepData.HiSpeedInit);
  530.     printf("Sysdependant Modem Unit %d Device:%s\n"
  531.     , cfg.DepData.UnitNumber, cfg.DepData.DevName);
  532.     printf("Sysdependant clock:%d\n",cfg.DepData.Clock);
  533.     printf("Sysdependant Lockport:%d\n",cfg.DepData.LockPort);
  534.     printf("Sysdependant width: %d Height: %d Depth: %d\n",
  535.     cfg.DepData.ScreenWidth,cfg.DepData.ScreenHeight,cfg.DepData.ScreenDepth);
  536.     printf("Sysdependant Colors:%d %d\n",cfg.DepData.Color0, cfg.DepData.Color1);
  537.  
  538.     };
  539.  
  540.   }
  541. void Do_Boolean(str,flag,control)
  542. char *str;
  543. short flag,control;
  544.   {
  545.   printf("%s: %s%c",str,(flag!=0 ? "Yes  " : "No   "),(control ? '\n' : ' ') );
  546.  
  547.   }
  548. void Verify_Log()
  549.   {
  550.   short i;
  551.   initLogBuf(&logBuf);
  552.   for ( i = 0; i < cfg.MAXLOGTAB; i++ )
  553.     {
  554.     getLog(&logBuf,i);
  555.     if( Lflag )printf("\nlog:%-4d",i);
  556.     if (logBuf.lbflags.L_INUSE)
  557.       {
  558.       showlog(i);
  559.       if( logBuf.lbwidth < 40 || logBuf.lbwidth > 132 )
  560.         {
  561.         printf("Log:%d,  %s terminal width = %d\n",i,logBuf.lbname,logBuf.lbwidth);
  562.  
  563.         };
  564.       if( logBuf.lbnulls > 50 )
  565.         {
  566.         printf("Log:%d,  %s terminal nulls = %d\n",i,logBuf.lbname,logBuf.lbnulls);
  567.  
  568.         };
  569.       if( logBuf.credit < 0 || logBuf.credit > 1000)
  570.         {
  571.         printf("Log:%d,  %s Long Distance credits = %d\n",i,logBuf.lbname,logBuf.credit);
  572.  
  573.         };
  574.  
  575.       }
  576.     else
  577.       {
  578.       if( Lflag )printf(" Not in use at this time\n");
  579.  
  580.       };
  581.  
  582.     };
  583.  
  584.   }
  585. void showlog(i)
  586. int i;
  587.   {
  588.   if( Lflag )
  589.     {
  590.     printf("%4d: %-20s",i,logBuf.lbname);
  591.     printf("%-20s",logBuf.lbpw);
  592.     ShowHash();
  593.     printf(" %d col. Last Call:%s\n",logBuf.lbwidth, LastOn(logBuf.lblaston, TRUE));
  594.     Do_Boolean("AIDE Status       ",logBuf.lbflags.AIDE      ,FALSE);
  595.     Do_Boolean("Expert User       ",logBuf.lbflags.EXPERT    ,FALSE);
  596.     Do_Boolean("Network Privilege ",logBuf.lbflags.NET_PRIVS ,TRUE);
  597.     Do_Boolean("Door Privilege    ",logBuf.lbflags.DOOR_PRIVS,FALSE);
  598.     Do_Boolean("Download Privilege",logBuf.lbflags.DL_PRIVS  ,FALSE);
  599.     Do_Boolean("Permanent Account ",logBuf.lbflags.PERMANENT ,TRUE);
  600.     Do_Boolean("Floor mode        ",logBuf.lbflags.FLOORS    ,FALSE);
  601.     Do_Boolean("TWIT User         ",logBuf.lbflags.TWIT      ,FALSE);
  602.     Do_Boolean("RUGGIE User       ",logBuf.lbflags.RUGGIE    ,TRUE);
  603.     Do_Boolean("Active Account    ",logBuf.lbflags.L_INUSE   ,FALSE);
  604.     Do_Boolean("LF FLAG           ",logBuf.lbflags.LFMASK    ,FALSE);
  605.     Do_Boolean("OLD STYLE         ",logBuf.lbflags.OLDTOO    ,TRUE);
  606.     Do_Boolean("HALF DUPLEX       ",logBuf.lbflags.HALF_DUP  ,FALSE);
  607.     Do_Boolean("ALT. Read Messages",logBuf.lbflags.ALT_RE    ,FALSE);
  608.     Do_Boolean("Room Name Prompt  ",logBuf.lbflags.NoPrompt  ,TRUE);
  609.  
  610.     };
  611.  
  612.   }
  613. void ShowHash()
  614.   {
  615.   int i;
  616.   for (i = 0; i < cfg.MAXLOGTAB; i++)
  617.   if (logTab[i].ltlogSlot == thisLog)
  618.     {
  619.     printf("ltab=%02d, hash=%02d\n ", logTab[i].ltpwhash, hash(logBuf.lbpw));
  620.  
  621.     }
  622.  
  623.   }
  624. void Do_Door_Data()
  625.   {
  626.   FILE        *fd;
  627.   SYS_FILE    name;
  628.   DoorData    DoorInfo;
  629.   extern char *READ_ANY;
  630.   short flag;
  631.   makeSysName(name, DOOR_DATA, &cfg.roomArea);
  632.   if ((fd = safeopen(name, READ_ANY)) == NULL)
  633.     {
  634.     if( Dflag )printf("No doors appear to be available.\n ");
  635.     return;
  636.  
  637.     };
  638.   /* process each door */
  639.   while ( fread((char *)&DoorInfo, sizeof DoorInfo, 1, fd) != 0)
  640.     {
  641.     if( Dflag)
  642.       {
  643.       printf("\nDoor Code:%s Program:%s Room:%s\n"
  644.       ,DoorInfo.entrycode,DoorInfo.program,DoorInfo.RoomName);
  645.       printf("Parameters:%s\n",DoorInfo.parameters);
  646.       printf("Description:%s\n",DoorInfo.description);
  647.       printf("Location:%s TimeLimit:%d\n",DoorInfo.location,DoorInfo.TimeLimit);
  648.       flag = (DOOR_AIDE    & DoorInfo.flags) ? 1:0;
  649.       Do_Boolean("   AIDE",flag,FALSE);
  650.       flag = (DOOR_SYSOP   & DoorInfo.flags) ? 1:0;
  651.       Do_Boolean("  SYSOP",flag,FALSE);
  652.       flag = (DOOR_CON     & DoorInfo.flags) ? 1:0;
  653.       Do_Boolean("Console",flag,TRUE);
  654.       flag = (DOOR_MODEM   & DoorInfo.flags) ? 1:0;
  655.       Do_Boolean("  Modem",flag,FALSE);
  656.       flag = (DOOR_AUTO    & DoorInfo.flags) ? 1:0;
  657.       Do_Boolean("   Auto",flag,FALSE);
  658.       flag = (DOOR_NEWUSER & DoorInfo.flags) ? 1:0;
  659.       Do_Boolean("NewUser",flag,TRUE);
  660.       printf("\n");
  661.  
  662.       };
  663.  
  664.     };
  665.  
  666.   }
  667. /*
  668. * doMessages()
  669. *
  670. * This function loops thru the msg file until finished.  It accumulates
  671. * statistics, etc.
  672. */
  673. extern MessageBuffer  msgBuf; /* The -sole- message buffer      */
  674. extern FILE *msgfl, *msgfl2;
  675.  
  676. struct counts
  677.   {
  678.   struct counts *next;
  679.   char name[20];    /* room name */
  680.   long  messages;   /* number of messages in the room */
  681.   long bytes;       /* total space the message uses */
  682.  
  683.   };
  684. struct counts *Header;
  685.  
  686. void Process_Msg(MessageBuffer  *msg)
  687.   {
  688.   struct counts *ptr, *uptr;
  689.   int done;
  690. /*
  691. ** User names Statistics
  692. */
  693.   if( Header = NULL )
  694.     {
  695.     Header = ptr = malloc(sizeof(struct counts));
  696.     strcpy(ptr->name, msg->mbauth);
  697.     ptr->messages = 0;
  698.     ptr->bytes    = 0;
  699.     ptr->next     = NULL;
  700.     }
  701.   else
  702.     {
  703.     ptr = Header;
  704.     done= FALSE;
  705.     while( ptr != NULL && !done)
  706.       {
  707.       if( strcmp(msg->mbauth,ptr->name)== 0 )done=TRUE;
  708.       if( !done )
  709.         {
  710.         uptr = ptr;
  711.         ptr = ptr->next;
  712.         };
  713.       };
  714.     };
  715.   if( ptr == NULL )
  716.     {
  717.     ptr = malloc(sizeof(struct counts));
  718.     strcpy(ptr->name, msg->mbauth);
  719.     ptr->messages = 0;
  720.     ptr->bytes    = 0;
  721.     ptr->next     = NULL;
  722.     uptr->next    = ptr;
  723.     };
  724.   ptr->messages++;
  725.   ptr->bytes += MsgLen(msg);
  726. /*
  727. ** Room Statistics
  728. */
  729.   ptr = Header;
  730.   done= FALSE;
  731.   while( ptr != NULL && !done)
  732.     {
  733.     if( strcmp(msg->mbroom,ptr->name)== 0 )done=TRUE;
  734.     if( !done )
  735.       {
  736.       uptr = ptr;
  737.       ptr = ptr->next;
  738.       };
  739.     };
  740.   if( ptr == NULL )
  741.     {
  742.     ptr = malloc(sizeof(struct counts));
  743.     strcpy(ptr->name, msg->mbauth);
  744.     ptr->messages = 0;
  745.     ptr->bytes    = 0;
  746.     ptr->next     = NULL;
  747.     uptr->next    = ptr;
  748.     };
  749.   ptr->messages++;
  750.   ptr->bytes += MsgLen(msg);
  751.  
  752.   }
  753.  
  754. void Print_Counts(struct counts *ptr )
  755.   {
  756.   if( ptr != NULL )
  757.     {
  758.     if( ptr->messages <= 0)ptr->messages = 1;
  759.     printf("Name:%20s Messages:%10ld Bytes:%10ld Aver:%10ld\n"
  760.     ,ptr->name,ptr->messages, ptr->bytes, ptr->bytes/ptr->messages);
  761.     Print_Counts(ptr->next);
  762.     };
  763.   }
  764.  
  765. void Do_Room_Stats(long total)
  766.   {
  767.   printf("Total of %ld messages\n",total);
  768.   Print_Counts( Header );
  769.   }
  770.  
  771. void Verify_Messages()
  772.   {
  773.   MSG_NUMBER msg, firstMessage;
  774.   MSG_NUMBER total;     /* For stat keeping. */
  775.   extern struct mBuf mFile1;
  776.   if( !Mflag ) return;
  777.   Header = NULL;
  778.   fprintf(stderr, "Mulching...\n");
  779.   InitMsgBase();
  780.   startAt(msgfl, &mFile1, 0, 0);
  781.   getMessage(getMsgChar, FALSE, TRUE, TRUE);
  782.   firstMessage = atol(msgBuf.mbId);
  783.   Do_Message(&msgBuf,TRUE);
  784.   msg = firstMessage -1;
  785.   total = 0;
  786.   while (msg != firstMessage)
  787.     {
  788.     total++;
  789.     getMessage(getMsgChar, FALSE, TRUE, TRUE);
  790.     Do_Message(&msgBuf, FALSE);
  791.     msg = atol(msgBuf.mbId);
  792.  
  793.     }
  794.   Do_Room_Stats(total);
  795.  
  796.   }
  797. void Do_Message(MessageBuffer  *msg, int flag)
  798.   {
  799.   Process_Msg(msg);
  800.   if( MControl == 'A')
  801.     {
  802.     printf("\nMsg: %6d Sector ID: %6d Author:%s To:%s "
  803.     ,  msg->mbheadChar, msg->mbheadSector, msg->mbauth, msg->mbto);
  804.     printf("Name:%s ID:%s Room:%s\n",  msg->mboname,  msg->mborig,  msg->mbroom);
  805.     }
  806.   else
  807.     {
  808.     printf("Message %6d Sector ID: %6d Author:%s\n",  msg->mbheadChar, msg->mbheadSector, msg->mbauth);
  809.     printf("Date:%20s Time:%20s Local Id:%20s\n",  msg->mbdate,  msg-> mbtime,  msg-> mbId);
  810.     printf("Human:%20s ID:%20s Room:%20s\n",  msg->mboname,  msg->mborig,  msg->mbroom);
  811.     printf("Origin:%20s To:%20s\n",  msg->mbsrcId,  msg->mbto);
  812.     printf("Route:%s\n", msg->mbaddr);
  813.     printf("OtherNet:%s\n",msg->mbOther);
  814.     printf("reply:%20s Domain:%20s\n",msg->mbreply, msg->mbdomain);
  815.     };
  816.   }
  817. /*
  818. * MsgLen()
  819. *
  820. * This function figures out the byte usage of the message.
  821. */
  822. int MsgLen(MessageBuffer  *msg)
  823.   {
  824.   return  (int) (       strlen(msg->mbtext)  + strlen(msg->mbauth) +
  825.   strlen(msg->mbdate)  + strlen(msg->mbtime) +
  826.   strlen(msg->mbId)    + strlen(msg->mboname) +
  827.   strlen(msg->mborig)  + strlen(msg->mbroom) +
  828.   strlen(msg->mbsrcId) + strlen(msg->mbto) +
  829.   strlen(msg->mbaddr)  + strlen(msg->mbOther) );
  830.  
  831.   }
  832. void Do_NetBuf_Data(int slot)
  833.   {
  834.   printf("\nSlot:%2d Node Name:%-22s  Node Id: %s\n",slot,netBuf.netName, netBuf.netId);
  835.   printf("Short Name:%c%c%c  Passwords: Our(%s) Their(%s)\n",
  836.   (isprint(netBuf.nbShort[0]) ? netBuf.nbShort[0] : '*'),
  837.   (isprint(netBuf.nbShort[1]) ? netBuf.nbShort[1] : '*'),
  838.   (isprint(netBuf.nbShort[2]) ? netBuf.nbShort[2] : '*'),
  839.   netBuf.OurPwd, netBuf.TheirPwd);
  840.   printf("baudCode:%d nbGen: %d access:%s\n",
  841.   (int)netBuf.baudCode, (int)netBuf.nbGen, netBuf.access);
  842.   printf("nbRoute:%d nbRouteGen:%d nbHiRouteInd: %d nbLastConnect: %x\n",
  843.   netBuf.nbRoute, netBuf.nbRouteGen, netBuf.nbHiRouteInd, netBuf.nbLastConnect);
  844.   Do_nflags(&netBuf.nbflags);
  845.   Do_Multi_Net_Data(netBuf.MemberNets);
  846.   Do_Shared_Room(netBuf.netRooms);
  847.  
  848.   }
  849.